/**
 * 创建新的结点作为head，连接原有的链表后循环遍历，找到需要删除的结点
*/

const removeElements = function (head, val) {
  const newNode = new ListNode(0)
  newNode.next = head
  let current = newNode
  while (current.next !== null) {
    if (current.next.val === val) {
      current.next = current.next.next
    } else {
      current = current.next
    }

  }
  return newNode.next
}